import React from 'react'
import './Footer.css'

export default function Footer(props) {
  const {list,changeAll}=props

  const statusChange=(e)=>{
    console.log(e.target.checked)
    changeAll(!list.every(i=>i.isChoose))
  }

  return (
    <div className='cart-footer'>
      <span><input type="checkbox" checked={list.every(i=>i.isChoose)} onChange={statusChange}/>全选</span>
      <span>价格总计 ￥{list.reduce((p,c)=>{if(c.isChoose)p+=c.price;return p},0)}</span>
    </div>
  )
}
